angular.module('charityApp').component('headerCharity', {
    templateUrl: 'app/header/header-charity.template.html',
    controller: ['$state','$location','$scope','$userService', function ($state, $location,$scope,$userService) {
        console.log($location.path());
        // this.currentView = $state.current.name ? $state.current.name : 'home';
        console.log(this.currentView);
        $.context.open(GLOBAL_SESSION);
        $scope.currentUser = $.context.session.user;
        this.aClick = function (item) {
            this.currentView = item;
            $state.go(item);
        }
        this.navClicked = function (item, articleType) {
            console.log(item);
            $state.go(item, {articleType: articleType});
        };

        $scope.logout = function () {
            $userService.logout();
            $.context.session.user = null;
            $.context.dme(GLOBAL_SESSION);
            $location.url('/');
        };


        $scope.$watch(function() {
            return $.context.session.user;
        }, function(currentUser) {
            $scope.currentUser = currentUser;
        });
    }]
});